<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <script type="text/javascript" th:src="@{/js/jquery-2.1.4.min.js}" src="/js/jquery-2.1.4.min.js"></script>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .demo{width:700px; margin:40px auto 0 auto; min-height:450px;}
        @media screen and (max-width: 360px) {.demo {width:340px}}

        .front{width: 300px;margin: 5px 32px 45px 32px;background-color: #f0f0f0;	color: #666;text-align: center;padding: 3px;border-radius: 5px;}
        .booking-details {float: right;position: relative;width:200px;height: 450px; }
        .booking-details h3 {margin: 5px 5px 0 0;font-size: 16px;}
        .booking-details p{line-height:26px; font-size:16px; color:#999}
        .booking-details p span{color:#666}
        div.seatCharts-cell {color: #182C4E;height: 25px;width: 25px;line-height: 25px;margin: 3px;float: left;text-align: center;outline: none;font-size: 13px;}
        div.seatCharts-seat {color: #fff;cursor: pointer;-webkit-border-radius: 5px;-moz-border-radius: 5px;border-radius: 5px;}
        div.seatCharts-row {height: 35px;}
        div.seatCharts-seat.available {background-color: #B9DEA0;}
        div.seatCharts-seat.focused {background-color: #76B474;border: none;}
        div.seatCharts-seat.selected {background-color: #E6CAC4;}
        div.seatCharts-seat.unavailable {background-color: #472B34;cursor: not-allowed;}
        div.seatCharts-container {border-right: 1px dotted #adadad;width: 400px;padding: 20px;float: left;}
        div.seatCharts-legend {padding-left: 0px;position: absolute;bottom: 16px;}
        ul.seatCharts-legendList {padding-left: 0px;}
        .seatCharts-legendItem{float:left; width:90px;margin-top: 10px;line-height: 2;}
        span.seatCharts-legendDescription {margin-left: 5px;line-height: 30px;}
        .checkout-button {display: block;width:80px; height:24px; line-height:20px;margin: 10px auto;border:1px solid #999;font-size: 14px; cursor:pointer}
        #selected-seats {max-height: 150px;overflow-y: auto;width: 200px;}
        #selected-seats li{float:left; width:72px; height:26px; line-height:26px; border:1px solid #d3d3d3; background:#f7f7f7; margin:6px; font-size:14px; font-weight:bold; text-align:center}
    </style>
</head>
<body>
    <div class="box" style="margin-left: 370px ">
        <!--档次:<span id="leaveSpan"></span>-->
        <div class="front">舞台</div>
        <div id="seat-map" ></div>
        <button onclick="backPage()">返回</button>
    </div>
</body>
<script>
    //获取场次
    var sessionId = [[${sessionId}]];
    var arr = null;
    //查座位信息
    $.ajax({
        url:"/goodsConsummer/getSiteInfo",
        data:{id:sessionId},
        success:function(data){
            //json转成数组
            console.log(data)
            arr = JSON.parse(data);
            createSite();
        }
    })
    //创建座位
    function createSite(){
        var str="";
        var styl='';
        for(var i=0;i<arr.length;i++){
            str+="<div class='seatCharts-row'>";
            str+="<div class='seatCharts-cell seatCharts-space'>"+i+"</div>";
            for(var j=0;j<arr[i].length;j++){
                //判断是否为不可选座位
                if(arr[i][j][1]==0){
                    clas="seatCharts-cell seatCharts-space";
                }else{
                    //判断是否设置了档次
                    console.log(arr[i][j][1]!=-1)
                    if(false){
                        clas="seatCharts-seat seatCharts-cell unavailable";
                        styl="style='background-color:grey'";
                    }else{
                        styl='';
                        //判断座位是否被选
                        if(arr[i][j][0]==0){
                            clas="seatCharts-seat seatCharts-cell available";
                        }else {
                            clas="seatCharts-seat seatCharts-cell unavailable";
                        }
                    }
                }
                str+="<div id=\""+i+"_"+j+"\" role=\"checkbox\" tabindex=\"-1\" class=\""+clas+"\" "+styl+" data-x='"+i+"' data-y='"+j+"'>"+arr[i][j][1]+"</div>"
            }
            str+="</div>";
        }
        $("#seat-map").html(str);
    }
    //返回
    function backPage(){
        location.href="/jumpPage/jumpPage?page=siteManage";
    }
</script>
</html>